<template>
	<view>
		<u-navbar :title="title + '记录'" :autoBack="true" :placeholder="true" leftIconColor="#ffffff"  :titleStyle="{color: '#ffffff'}" bgColor="#e60000" class="navBarHeight">
            <view slot="right" class="color-w font-14" @click="goTo">余额互转</view>
		</u-navbar>
		<view class="padding-sm border-bottom" v-for="(item, index) in walletList" :key="index">
			<view class="flex justify-between font-14 text-bold">
				<view>{{item.incomeFlag ? '收入' : '支出'}}</view>
				<view class="text-theme">￥{{item.amount}}</view>
			</view>
			<view class="padding-tb-xs text-theme">当前{{title}}：{{item.afterAmount}}</view>
			<view class="word-break text-gray">备注：{{item.remark}}</view>
			<view class="padding-top-xs text-gray">时间：{{item.createTime}}</view>
		</view>
		<u-loadmore :status="status" class="padding-bottom" />
	</view>
</template>

<script>
	import {
		walletFlow
	} from '@/common/api/customer.js'
	export default {
		data() {
			return {
				title: '',
				pageNo: 0,
				walletList: [],
				status: 'loading',
				walletType: '',
				incomeFlag: null,
                transfer: false
			};
		},
		onLoad(options) {
			this.walletType = options.walletType
			if(options.incomeFlag) {
				this.incomeFlag = options.incomeFlag
			}
			this.title = options.title

            if(this.title == '商城余额'){
                this.transfer = true
            }
		},
		onShow() {
			this.pageNo = 0
			this.walletList = []
			this.getwalletFlow()
		},
		onReachBottom() {
			this.getwalletFlow()
		},
		methods: {

            goTo(){
              uni.navigateTo({
                  url: '/pages/my/wallet/balanceTransfer'
              })
            },

			getwalletFlow(walletType) {
				this.pageNo++
				this.status = 'loading'
				let params = {
					pageNo: this.pageNo,
					pageSize: 10
				}
				if(this.incomeFlag != null) {
					params.incomeFlag = this.incomeFlag
				}
				walletFlow(params,this.walletType).then(res => {
					this.walletList = this.walletList.concat(res.data)
					if (res.data.length < 10) {
						this.status = 'nomore'
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
